import axios from 'axios';
import queryString from 'qs';

export const getSystemConfig = params => {
  return axios.get(
    `/api/system/getSystemConfig?${queryString.stringify(params, { indices: false })}`
  );
};

export const updateSystemConfig = body => {
  return axios.post('/api/system/updateSystemConfig', body);
};

export const checkLdapConnection = body => {
  return axios.post('/api/system/checkLDAPConnection', body);
};

export const updateLDAPDataByHand = () => {
  return axios.post('/api/system/updateLDAPData');
};

export const getOnedayConfig = () => {
  return axios.get('/api/system/oneday-config');
};

export const updateOnedayConfig = body => {
  return axios.post('/api/system/oneday-config', body);
};

export const postZoomeyeSearchConfig = body => {
  return axios.post('/api/system/config/zoomeyeOrg', body);
};

export const getZoomeyeSearchConfig = () => {
  return axios.get('/api/system/config/zoomeyeOrg');
};

export const updateZoomeyeOrg = () => {
  return axios.post('/api/system/zoomeyeOrgAsset/sync');
};

export const getZoomeyeOrgConnect = () => {
  return axios.get('/api/system/checkZoomeyeOrgConnection');
};

export const setZoomeyeOrgAccount = body => {
  return axios.post('/api/system/checkZoomeyeOrgConnection', body);
};

/**
 * 获取服务器时间
 * */
export const getServerTime = () => {
  return axios.get('/api/system/timestamp');
};

export const defaultScanInterface = () => {
  return axios.get('/api/system/defaultScanInterface');
};

export const getStaffinfo = query => {
  return axios.get(`/api/system/staff/info?${query}`);
};

export const getSftp = () => {
  return axios.get('/api/system/sftp/config');
};

export const setSftp = body => {
  return axios.post('/api/system/sftp/update', body);
};

// 适配器管理
export const getAdapterList = query => {
  return axios.get(`/api/system/adapter?${queryString.stringify(query, { indices: false })}`);
};

// 添加适配器
export const addAdapterList = body => {
  return axios.post('/api/system/adapter', body);
};

// 编辑适配器
export const editAdapterList = body => {
  return axios.put('/api/system/adapter', body);
};

// 删除适配器
export const deleteAdapter = query => {
  return axios.delete(`/api/system/adapter?${queryString.stringify(query, { indices: false })}`);
};

// 适配器列表
export const getAdapterManufacturerList = () => {
  return axios.get('/api/system/adapter/manufacturerList');
};

// 适配器字段列表
export const getAdapterManufacturerFieldList = () => {
  return axios.get('/api/system/adapter/manufacturerFieldList');
};
